//
//  UIBarButtonItem+Extension.swift
//  doudou_weibo
//
//  Created by apple on 2016/11/12.
//  Copyright © 2016年 apple. All rights reserved.
//

import UIKit

extension UIBarButtonItem{
    
    
    convenience init(title: String? = "", imageName: String, target: Any?, action: Selector?) {
        
        self.init()
        
        let button = UIButton()
        
        button.setTitle(title, for: .normal)
        button.titleLabel?.font = UIFont.systemFont(ofSize: 14)
        button.setTitleColor(#colorLiteral(red: 0.2549019754, green: 0.2745098174, blue: 0.3019607961, alpha: 1), for: .normal)
        button.setTitleColor(#colorLiteral(red: 1, green: 0.5781051517, blue: 0, alpha: 1), for: .highlighted)
        
        button.setImage(UIImage.init(named: imageName), for: .normal)
        button.setImage(UIImage.init(named: imageName + "_highlighted"), for: .highlighted)
        if let ac = action {
            button.addTarget(target, action: ac, for: .touchUpInside)
        }
        
        button.sizeToFit()
        
        self.customView = button

    }
    
    
    
    
    
    
}


